<template>
  <div class="home">
    <transition
      enter-active-class="animated fadeInLeft"
      mode="out-in" appear>
      <div v-show="show">
        <HelloWorld msg="香宝许愿"/>

        <div v-if="dt !== ''">{{dt}}</div>
      </div>
    </transition>

    <transition
      enter-active-class="animated fadeInLeft"
      mode="out-in" appear>
      <div v-show="!show">
        sdfdsfs
      </div>
    </transition>

    <div>
      <van-button type="primary" @click="show = !show">当前页面切换动画</van-button>
    </div>

    <div class="tabbar-box">
      <van-tabbar v-model="active">
        <van-tabbar-item icon="home-o" to="/">首页</van-tabbar-item>
        <van-tabbar-item icon="location-o" to="/login">登录</van-tabbar-item>
        <van-tabbar-item icon="qr" to="/about">关于</van-tabbar-item>
      </van-tabbar>
    </div>
  </div>
</template>

<script>
import { getHomeInfo } from "@/api/home";
import { Tabbar, Button, TabbarItem } from "vant";
import HelloWorld from "@/components/HelloWorld";

export default {
  name: "home",
  data() {
    return {
      active: 0,
      dt: "",
      show: true
    };
  },
  components: {
    "van-tabbar": Tabbar,
    "van-tabbar-item": TabbarItem,
    "van-button": Button,
    HelloWorld
  },
  created() {
    this.getIndexInfo();
  },
  methods: {
    getIndexInfo() {
      getHomeInfo()
        .then(res => {
          this.dt = res.data;
          //console.log(this.dt);
        })
        .catch(err => {
          console.log(err);
        });
    }
  }
};
</script>
